<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>一朵</title>
    <!-- swiper-2.7css -->
    <link rel="stylesheet" href="__STATIC__/index/js/swiper/idangerous.swiper.css">
    <!-- swiper-2.7js -->
    <script src="__STATIC__/index/js/swiper/idangerous.swiper.min.js"></script>
    <!-- jquery-3.2.1引用 -->
    <script src="__STATIC__/index/js/global/jquery-3.2.1.min.js"></script>
    <!-- 阿里巴巴矢量图库 -->
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_561814_qe0xuq9cng3c8fr.css">
    <!-- 公共头部 脚部 -->
    <link rel="stylesheet" href="__STATIC__/index/css/global/global.css">
    <!-- 超过1200屏幕 -->
    <link rel="stylesheet" media="screen and (min-width: 1200px)" href="__STATIC__/index/css/goods/goods1200.css" />
    <!-- 1080-1200 -->
    <link rel="stylesheet" media="screen  and (min-width: 1080px) and (max-width: 1199px) " href="__STATIC__/index/css/goods/goods1080.css"
    />
    <!-- 960-1080 -->
    <link rel="stylesheet" media="screen  and (min-width: 960px) and (max-width: 1079px) " href="__STATIC__/index/css/goods/goods960.css"
    />
    <!-- 768-959 -->
    <link rel="stylesheet" media="screen  and (min-width: 768px) and (max-width: 959px) " href="__STATIC__/index/css/goods/goods768.css"
    />
    <!-- 568-767 -->
    <link rel="stylesheet" media="screen  and (min-width: 568px) and (max-width: 767px) " href="__STATIC__/index/css/goods/goods568.css"
    />
    <!-- 375-567 -->
    <link rel="stylesheet" media="screen  and (min-width: 375px) and (max-width: 567px) " href="__STATIC__/index/css/goods/goods375.css"
    />
    <!--引入layer-->
    <script src="__STATIC__/layer/layer.js"></script>
    <!-- 小于375-->
    <link rel="stylesheet" media="screen  and (max-width: 374px) " href="__STATIC__/index/css/goods/goods320.css" /> {include file="public/page_css" /}
</head>

<body>
    <!-- ----------------------------- 移动端内容 ------------------------------------ -->
    <form action="{:url('GoodsList/pre_create_order')}" id="p_form" method="post">
        <div class="M">
            <div class="m-header">
                <div>
                    <span onclick="go_back();">
                        <span class="iconfont icon-xiangzuo" onclick="go_back();"></span>
                        返回
                    </span>
                    <span>商品详情</span>
                    <span>
                        {if condition="!empty($realname)"}
                        <a href="{:url('User/index')}" class="my">
                            {$realname}
                        </a>
                        {else /}
                        <a href="{:url('Login/loginin')}">登录</a>
                        <a href="{:url('Login/register')}">注册</a>
                        {/if}
                        <a href="{:url('MyCart/my_cart')}" class="car">
                            <span class="iconfont icon-gouwuche"></span>
                            <span>{$cart_num}</span>
                        </a>
                    </span>
                </div>
            </div>
            <div class="m-carousel">
                <div class="swiper-container1">
                    <div class="swiper-wrapper">
                        {foreach name="goods.images" item="v"} {if condition="!empty($v)"}
                        <div class="swiper-slide">
                            <img src="{$v}" alt="">
                        </div>
                        {/if} {/foreach}
                    </div>
                </div>
                <div class="pagination1"></div>
            </div>
            <div class="m-headline">
                <p>购买 {$goods.name}</p>
                <p>{$goods.subtitle}</p>
                <p>产品口味</p>
                <p>
                    {$goods.taste}
                </p>
            </div>
            <!-- 详情和评论切换 -->
            <div class="m-total">
                <p>
                    <span class="xiangqing qiehuan">产品详情</span>
                    <span class="pingLun m_pinglun">买家评价</span>
                </p>
            </div>
            <!-- 详情展示 -->
            <div class="details">
                <div>
                    {$goods.detail}
                </div>
            </div>
            <!-- 评论展示 -->
            <div class="comment">
                {if condition="!empty($pinglun)"}
                <div class="m_pingjia_content">
                    <!-- 评价循环开始 -->
                    {foreach name="pinglun" item="v"}
                    <div>
                        <div>
                            <img src="{if condition='!empty($v.logo)'}{$v.logo}{else /}__STATIC__/index/touxiang.png{/if}" alt="">
                        </div>
                        <div>
                            <p>
                                <span>{if condition="!empty($v.realname)"}{$v.realname}{else /}匿名{/if}</span>
                                <span>{$goods.name}</span>
                                <span>{$v.addtime|date="Y-m-d",###}</span>
                            </p>
                            <p>{$v.content}</p>
                            {if condition="!empty($v.images)"}
                            <div>
                                {foreach name="v.images" item="vo"}
                                <img src="{$vo}" alt=""> {/foreach}
                            </div>
                            {/if}
                        </div>
                    </div>
                    {/foreach}
                    <!--  {foreach name="pinglun" item="v"}
                    <div>
                        <div>
                            <div>
                                <img src="{if condition='!empty($v.logo)'}{$v.logo}{else /}__STATIC__/index/touxiang.png{/if}" alt="">
                            </div>
                            <p>{if condition="!empty($v.realname)"}{$v.realname}{else /}匿名{/if}</p>
                            <span>{$v.spec_title}</span>
                        </div>
                        <div>
                            <p>{$v.content}</p>
                            {if condition="!empty($v.images)"}
                            <div>
                                {foreach name="v.images" item="vo"}
                                <div>
                                    <img src="{$vo}" alt="">
                                </div>
                                {/foreach}
                            </div>
                            {/if}
                        </div>
                        <div>
                            <p>{$v.addtime|date="Y-m-d",###}</p>
                            <p>
                                <span>{$goods.name}</span>
                                <span>{$v.spec_title}</span>
                            </p>
                        </div>
                    </div>
                    {/foreach} -->
                    <!-- 评价循环结束 -->
                    <!--<p class="asd">已经到底了</p>-->
                </div>
                {/if} {if condition="empty($pinglun)"}
                <div class="m-kong">
                    <img src="__STATIC__/index/img/goods/kong.png" alt="">
                    <p>您看的这个商品 暂无评价</p>
                    <p>······</p>
                </div>
                {/if}
            </div>
            <div class="m-bottom">
                <div>
                    <span class="iconfont icon-shoucang1 yishoucang" id="" {if condition="$is_collect neq 1" } style="display:none;" {/if}></span>
                    <span class="iconfont icon-shoucang shoucang" id="" {if condition="$is_collect neq 0" } style="display:none;" {/if}></span>
                </div>
                <div class="buy">¥
                    <span class="p_price">{$goods.price}</span> 购买</di>
                </div>
            </div>
            <div class="popups">
                <div class="popups-content">
                    <div>
                        <img src="{$goods.logo}" alt="">
                        <span class="iconfont icon-cuowu" id="close"></span>
                    </div>
                    <div>
                        <p>购买 {$goods.name}</p>
                        {if condition="($goods.member_level_id gt 1) AND ($member.level_id egt $goods.member_level_id)"}
                        <span class="p_price">
                            {$goods.member_price}
                        </span>
                        {if condition="$goods.member_level_id eq 2"}
                        <span>黄金会员特价</span>
                        {elseif condition="$goods.member_level_id eq 3"}
                        <span style="background-color: #ff4c4c;">铂金会员特价</span>
                        {elseif condition="$goods.member_level_id eq 4"}
                        <span style="background-color: #d336ff;">钻石会员特价</span>
                        {/if} {else /}
                        <span class="p_price">
                            ￥{$goods.price}
                        </span>
                        <!--<span></span>-->
                        {/if}
                    </div>
                    <!--商品属性 start-->
                    <div class="m-xiangqing">
                         {volist name="spec_name" id="v" key="kk"}
                        <div class="xunhuan">
                            <p>选择{$v.name}</p>
                            <div>
                                {foreach name="spec_result" item="v1" } {if condition="$v1.spec_id eq $v.id"}
                                <div class="PC-kouwei m_spec_{$v1.id} m_change_spec_{$kk}" data-spec="{$v.name}" data-spec-id="{$v1.id}" onclick="m_change_spec(this,{$kk},{$v1.id});">
                                    {$v1.detail}
                                </div>
                                {/if} {/foreach}
                            </div>
                        </div>
                        {/volist}
                    </div>
                    <!--商品属性 end-->
                    <!-- 移动端数量选择 -->
                    <div class="shuliang">
                        <p>数量</p>
                        <div>
                            <input type="button" class="add" value="+">
                            <input type="text" class="text_box" value="1" readonly="value">
                            <input type="button" class="min" value="—" style="color: rgb(205, 205, 205);">
                            <span>库存：
                                <span class="kucun">{$goods.stock}</span>
                            </span>
                            <!-- 库存 -->
                        </div>
                    </div>
                    <!-- 移动端提交按钮 -->
                    <div class="tijiao">
                        {if condition="empty($store_goods_id)"}
                        <!--有属性商品-->
                        <a href="javascript:;" onclick="addto_cart(1);">加入购物车</a>
                        {else /}
                        <!--无属性商品-->
                        <a href="javascript:;" onclick="addto_cart(2);">加入购物车</a>
                        {/if}
                        <a href="javascript:;" onclick="p_check_form();">立即购买</a>
                    </div>
                </div>
            </div>
        </div>
        <!-- ----------------------------- PC端内容 ------------------------------------ -->
        <div class="PC">
            {include file="public/p_header" /}
            <!-- 内容 -->
            <div class="content">
                <div class="column">
                    <div>
                        <span>
                            <a href="{:url('Index/index')}">HOME</a>
                        </span> /
                        <span>
                            <a href="{:url('GoodsList/goods_list')}">分类</a>
                        </span> /
                        <span>
                            <a href="javascript:;">详情</a>
                        </span>
                    </div>
                    <div>
                        <input type="text" name="p_key" placeholder="点击搜索艺术美食 ">
                        <span class="iconfont icon-sousuo" onclick="search();"></span>
                    </div>
                </div>
                <div class="join">
                    <div class="join-left">
                        <div class="PC-carousel">
                            <div class="swiper-container">
                                <div class="swiper-wrapper">
                                    {foreach name="goods.images" item="v"} {if condition="!empty($v)"}
                                    <div class="swiper-slide">
                                        <img src="{$v}" alt="">
                                    </div>
                                    {/if} {/foreach}
                                    <!--<div class="swiper-slide">-->
                                    <!--<img src="__STATIC__/index/img/shanchu/dangao.png" alt="">-->
                                    <!--</div>-->
                                    <!--<div class="swiper-slide">-->
                                    <!--<img src="__STATIC__/index/img/shanchu/dangao.png" alt="">-->
                                    <!--</div>-->
                                </div>
                            </div>
                            <div class="pagination"></div>
                        </div>
                    </div>
                    <div class="join-right">
                        <div>
                            <div>购买 {$goods.name}</div>
                            <div>
                                {$goods.subtitle}
                            </div>
                        </div>
                        <p>产品口味</p>
                        <div>
                            {$goods.taste}
                        </div>
                        <div class="pc-xiangqing">
                        {volist name="spec_name" id="v" key="kk"}
                        <p class="pc-kouwei" id="spec_{$kk}">选择{$v.name}</p>
                        <div class="pc-kouwei-content">
                            {foreach name="spec_result" item="v1" } {if condition="$v1.spec_id eq $v.id"}
                                <div class="PC-kouwei spec_{$v1.id} change_spec_{$kk}" class="pc-red" data-spec="{$v.name}" data-spec-id="{$v1.id}" onclick="p_change_spec(this,{$kk},{$v1.id});">
                                    {$v1.detail}
                                </div>
                                <!--<p>适合5-6人分享</p>-->
                            {/if} {/foreach}
                        </div>
                        {/volist}
                        </div>
                        <p class="pc-number">选择数量</p>
                        <div class="pc-number-content">
                            <div>
                                <input type="button" class="add" value="+">
                                <input type="text" class="text_box" value="1" name="num" readonly="value">
                                <input type="button" class="min" value="—" style="color: rgb(205, 205, 205);">
                            </div>
                            <div>
                                <span>库存：</span>
                                <span class="kucun">{$goods.stock}</span>
                            </div>
                            <div>
                                    <span class="iconfont icon-shoucang1 yishoucang" {if condition="$is_collect neq 1" } style="display:none;" {/if}></span>
                                    <span class="yishoucang" {if condition="$is_collect neq 1" } style="display:none;" {/if}>已收藏</span>
                                    <span class="iconfont icon-shoucang shoucang"  {if condition="$is_collect neq 0" } style="display:none;" {/if}></span>
                                    <span class="shoucang" {if condition="$is_collect neq 0" } style="display:none;" {/if}>收藏</span> 
                            </div>
                           
                        </div>
                        <div class="pc-kucun">
                            <div>
                                {if condition="($goods.member_level_id gt 1) AND ($member.level_id egt $goods.member_level_id)"}
                                <span class="p_price">
                                    {$goods.member_price}
                                </span>
                                {if condition="$goods.member_level_id eq 2"}
                                <span>黄金会员特价</span>
                                {elseif condition="$goods.member_level_id eq 3"}
                                <span style="background-color: #ff4c4c;">铂金会员特价</span>
                                {elseif condition="$goods.member_level_id eq 4"}
                                <span style="background-color: #d336ff;">钻石会员特价</span>
                                {/if} {else /}
                                <span class="p_price">
                                    ￥{$goods.price}
                                </span>
                                <!--<span></span>-->
                                {/if}
                            </div>
                           
                        </div>
                        <div class="pc-goumai">
                            <!--检查商品提交 start-->
                            <a href="javascript:;" onclick="p_check_form();">立即购买</a>
                            {if condition="empty($store_goods_id)"}
                            <!--有属性商品-->
                            <a href="javascript:;" onclick="addto_cart(1);">加入购物车</a>
                            {else /}
                            <!--无属性商品-->
                            <a href="javascript:;" onclick="addto_cart(2);">加入购物车</a>
                            {/if}
                          
                        </div>
                    </div>
                </div>
                <!-- 公告 -->
                <div class="notice">
                    <div>
                        <span>{$goods.save_method}</span>
                        <span>最早明天10:00配送</span>
                    </div>
                </div>
                <!-- 公告结束 -->
                <!-- 详情和评论切换 -->
                <div class="total">
                    <p>
                        <span class="xiangqing qiehuan">产品详情</span>
                        <span class="pingLun">评论({$all_comment})</span>
                    </p>
                    <!-- 详情和评论切换结束 -->
                </div>
                <!-- 详情 -->
                <div class="details">
                    <div>
                        {$goods.detail}
                    </div>
                </div>
                <!-- 详情 -->
                <!-- 评论 -->
                <div class="comment">
                    {if condition="!empty($pinglun)"}
                    <div class="pingjia_content">
                        {foreach name="pinglun" item="v"}
                        <div>
                            <div>
                                <div>
                                    <img src="{if condition='!empty($v.logo)'}{$v.logo}{else /}__STATIC__/index/touxiang.png{/if}" alt="">
                                </div>
                                <p>{if condition="!empty($v.realname)"}{$v.realname}{else /}匿名{/if}</p>
                            </div>
                            <div>
                                <p>{$v.content}</p>
                                {if condition="!empty($v.images)"}
                                <div>
                                    {foreach name="v.images" item="vo"}
                                    <div>
                                        <img src="{$vo}" alt="">
                                    </div>
                                    {/foreach}
                                </div>
                                {/if}
                            </div>
                            <div>
                                <p>{$v.addtime|date="Y-m-d",###}</p>
                                <p>
                                    <span>{$goods.name}</span>
                                    <span>{$v.spec_title}</span>
                                </p>
                            </div>
                        </div>
                        {/foreach}
                    </div>
                    <!-- 翻页 -->
                    <div class="pc-Flip pages" style="text-align: center;">
                        {$page}
                    </div>
                    {/if} {if condition="empty($pinglun)"}
                    <div class="pc-kong">
                        <img src="__STATIC__/index/img/goods/kong.png" alt="">
                        <p>您看的这个商品 暂无评价</p>
                        <p>······</p>
                    </div>
                    {/if}
                </div>
                <!-- 评论 -->
            </div>
            {include file="public/p_footer" /}
        </div>
        <input type="hidden" name="p_spec_count" value="{$spec_count}">
        <input type="hidden" name="p_goods_id" value="{$goods.id}">
        <input type="hidden" name="p_spec_id" value=""> {if condition="empty($store_goods_id)"}
        <input type="hidden" name="p_id[]" value=""> {else /}
        <input type="hidden" name="p_id[]" value="{$store_goods_id}"> {/if}
        <div style="display:none;" id="cur_page">{$cur_page}</div>
        <div style="display:none" id="all_page">{$all_page}</div>
    </form>
    <script>
        $(function () {
            /* 详情和评论切换*/
            $('.xiangqing').click(function () {
                $('.details').show();
                $('.comment').hide();
                $('.xiangqing').addClass('qiehuan');
                $('.pingLun').removeClass('qiehuan');
            });
            $('.pingLun').click(function () {
                $('.comment').show();
                $('.details').hide();
                $('.pingLun').addClass('qiehuan');
                $('.xiangqing').removeClass('qiehuan');
            });
            /* 尺寸选择*/
            //            $('.PC-chicun').click(function () {
            //                if ($(this).hasClass('pc-chicun-red')) {
            //                    $(this).removeClass('pc-chicun-red');
            //                    return
            //                }
            //                $('.PC-chicun').removeClass('pc-chicun-red');
            //                $(this).addClass('pc-chicun-red');
            //            });
            /* 口味选择*/
            //            $('.PC-kouwei').click(function () {
            //                if ($(this).hasClass('pc-kouwei-red')) {
            //                    $(this).removeClass('pc-kouwei-red');
            //                    return
            //                }
            //                $('.PC-kouwei').removeClass('pc-kouwei-red');
            //                $(this).addClass('pc-kouwei-red');
            //            });
            /*上拉到底*/
            $(window).scroll(function () {
                if ($(document).scrollTop() >= $(document).height() - $(window).height() - 1) {
                    if ($('.m_pinglun').hasClass('qiehuan')) {
                        var goods_id = "{$goods.id}";
                        var cur_page = parseInt($('#cur_page').text()); //当前页码
                        var all_page = parseInt($('#all_page').text()); //当前页码
                        //                        console.log(cur_page);
                        //                        console.log(all_page);
                        var goods_name = "{$goods.name}";
                        if (all_page != cur_page) {
                            $.post("{:url('GoodsList/get_ajax_comment')}", {
                                    goods_id: goods_id,
                                    cur_page: cur_page
                                },
                                function (data) {
                                    if (data.code == 1) {
                                        var html = '';
                                        for (var i = 0; i < data.data.length; i++) {
                                            var realname = '';
                                            var images = '';
                                            var headerlogo = '';
                                            var logo = '';
                                            if (data.data[i]['images'] != '') {
                                                for (var ii = 0; ii < data.data[i]['images'].length; ii++) {
                                                    images += '<div><div><img src="' + data.data[i]
                                                        ["images"][ii] + '" alt=""></div></div>';
                                                }
                                            }
                                            if (data.data[i]['realname'] == '') {
                                                realname = '匿名';
                                            } else {
                                                realname = data.data[i]['realname'];
                                            }
                                            if (data.data[i]["logo"] == '') {
                                                logo = '__STATIC/__index/img/shanchu/touxiang.jpg';
                                            } else {
                                                logo = data.data[i]["logo"];
                                            }

                                            html += ' <div><div><img src="' + logo +
                                                '" alt=""></div><div><p><span>' + realname +
                                                '</span><span>' + goods_name + '</span><span>' +
                                                data.data[i][
                                                    "add_time"
                                                ] + '</span></p><p>' + data.data[i]["content"] +
                                                '</p>' + images + '</div></div>';
                                            // html += '<div><div><div><img src="' + logo +
                                            //     '" alt=""></div><p>' + realname +
                                            //     '</p></div><div><p>' + data.data[i]["content"] +
                                            //     '</p>' + images + '</div><div><p>' + data.data[i][
                                            //         "add_time"
                                            //     ] + '</p><p><span>' + goods_name + '</span><span>' +
                                            //     data.data[i]["spec_title"] +
                                            //     '</span></p></div></div>';
                                        }
                                        $('.m_pingjia_content').append(html);
                                        $('#cur_page').text(data.msg);
                                        if (cur_page + 1 == all_page) {
                                            $('.m_pingjia_content').append(
                                                '<p class="asd">已经到底了</p>');
                                        }
                                    }
                                }
                            );
                        } else {}
                    }
                }
            });
            /* 已经收藏*/
            $('.yishoucang').click(function () {
                var goods_id = "{$goods.id}";
                $.post("{:url('GoodsList/collect_goods')}", {
                        goods_id: goods_id
                    },
                    function (data) {
                        if (data.code == 1) {
                            layer.msg('取消成功', {
                                icon: 1,
                                time: 1500,
                                shade: 0.1
                            }, function (index) {
                                layer.close(index);
                                $('.yishoucang').css('display', 'none');
                                $('.shoucang').css('display', 'inline-block');
                            });
                            return false;
                        } else {
                            layer.msg('取消失败', {
                                icon: 2,
                                time: 1500,
                                shade: 0.1
                            }, function (index) {
                                layer.close(index);
                            });
                            return false;
                        }
                    }
                );
            });
            /* 收藏*/
            $('.shoucang').click(function () {
                var goods_id = "{$goods.id}";
                var spec_combin = '';
                var len = $('.pc-kouwei-red').length;
                var spec_num = "{$spec_count}";
                //                if (len == spec_num) {
                //                    $('.pc-kouwei-red').each(function () {
                //                        spec_combin += $(this).attr('data-spec-id') + ',';
                //                    })
                //                } else {
                //                    layer.msg('请选择商品属性', {
                //                        icon: 2,
                //                        time: 1500,
                //                        shade: 0.1
                //                    }, function (index) {
                //                        layer.close(index);
                //                    });
                //                    return false;
                //                }
                $.post("{:url('GoodsList/collect_goods')}", {
                        goods_id: goods_id,
                        spec_combin: spec_combin
                    },
                    function (data) {
                        if (data.code == 1) {
                            layer.msg('收藏成功', {
                                icon: 1,
                                time: 1500,
                                shade: 0.1
                            }, function (index) {
                                layer.close(index);
                                $('.shoucang').css('display', 'none');
                                $('.yishoucang').css('display', 'inline-block');
                            });
                            return false;
                        } else {
                            layer.msg(data.msg, {
                                icon: 2,
                                time: 1500,
                                shade: 0.1
                            }, function (index) {
                                layer.close(index);
                            });
                            return false;
                        }
                    }
                );
            });
            $(".add").click(function () {
                var kucun = $('.kucun').html();
                var t = $(this).parent().find('input[class*=text_box]');
                if (parseInt(t.val()) + 1 > kucun) {
                    $(".add").css("color", "#CDCDCD");
                    return;
                }
                t.val(parseInt(t.val()) + 1);
                if (parseInt(t.val()) > 1) {
                    $(".min").css("color", "#219dfd");
                }
                var x = parseInt(t.val());
                if (parseInt(t.val()) + 1 > kucun) {
                    $(".add").css("color", "#CDCDCD");
                    return;
                }
                $('input[class=text_box]').val(x);
            });
            $(".min").click(function () {
                var kucun = $('.kucun').html()
                var t = $(this).parent().find("input[class*=text_box]");
                if (parseInt(t.val()) - 1 < kucun) {
                    $(".add").css("color", "#219dfd");
                }
                t.val(parseInt(t.val()) - 1);
                if (parseInt(t.val()) < 2) {
                    t.val(1);
                    $(this).css("color", "#CDCDCD");
                }
                var x = parseInt(t.val());
                $('input[class=text_box]').val(x);
            });
            $('.remove').click(function () {
                console.log($(this))
                $(this).parent().parent().remove();
            });
            /* 手机端商品属性选择弹出层*/
            /*
             *打开弹出层 并固定body不能滑动
             */
            $('.buy').click(function () {
                $('body').css('overflow', 'hidden')
                $('.popups').css('display', 'block');
                $('.popups-content').animate({
                    bottom: "0",
                });
            });
            /*
             *关闭弹出层 并让body可以滑动
             */
            $('#close').click(function () {
                $('body').css('overflow', 'scroll')
                $('.popups').css('display', 'none');
                $('.popups-content').animate({
                    bottom: "-999px",
                });
            });
        });
        /**
         * PC端选择商品属性查询商品价格
         * @param obj
         * @param id    商品属性分类id
         * @param s_id    商品属性id
         */
        function p_change_spec(obj, id, s_id) {
            if ($(obj).hasClass('pc-chicun-red')) { //取消选中
                $(obj).removeClass('pc-chicun-red');
                $('.m_change_spec_' + id).removeClass('pc-kouwei-red');
                //                $('.m_spec_'+s_id).removeClass('pc-kowei-red');
                //                return
            } else {
                $('.change_spec_' + id).removeClass('pc-chicun-red');
                $('.m_change_spec_' + id).removeClass('pc-kouwei-red');
                $(obj).addClass('pc-chicun-red');
                $('.m_spec_' + s_id).addClass('pc-kouwei-red');
            }
            //            if($('.m_spec_'+s_id).hasClass('pc-kouwei-red')){
            //                $('.m_spec_'+s_id).removeClass('pc-kouwei-red');
            //            }else{
            //                $('.PC-kouwei').removeClass('pc-kouwei-red');
            //                $('.m_spec_'+s_id).addClass('pc-kouwei-red');
            //            }
            //            $('.change_spec_'+id).removeClass('pc-chicun-red');
            //            $(obj).addClass('pc-chicun-red');
            var spec_num = "{$spec_count}"; //商品属性数量
            var goods_id = $('input[name=p_goods_id]').val(); //商品id
            //商品属性组合
            var spec_combin = '';
            var len = $('.pc-chicun-red').length;
            if (len == spec_num) {
                $('.pc-chicun-red').each(function () {
                    spec_combin += $(this).attr('data-spec-id') + ',';
                })
            } else {
                return false;
            }
            $.post("{:url('GoodsList/pre_calculate_price')}", {
                    goods_id: goods_id,
                    specs: spec_combin
                },
                function (data) {
                    if (data.code == 1) {
                        $('input[name="p_id[]"]').val(data.data.id);
                        $('.p_price').text(data.data.price);
                        $('.kucun').text(data.data.stock);
                    } else {
                        //                        $('input:radio[name^="spec_"]').removeAttr('checked');
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                            $(obj).removeClass('pc-chicun-red');
                            $('.m_spec_' + s_id).removeClass('pc-kouwei-red');
                        });
                        return false;
                    }
                }
            );
        }
        /**
         * 移动端选择商品属性查询商品价格
         * @param obj
         * @param id    商品属性分类id
         * @param s_id    商品属性id
         */
        function m_change_spec(obj, id, s_id) {
            if ($(obj).hasClass('pc-kouwei-red')) {
                $(obj).removeClass('pc-kouwei-red');
                $('.change_spec_' + id).removeClass('pc-chicun-red');
                //                return
            } else {
                $('.m_change_spec_' + id).removeClass('pc-kouwei-red');
                $('.change_spec_' + id).removeClass('pc-chicun-red');
                $(obj).addClass('pc-kouwei-red');
                $('.spec_' + s_id).addClass('pc-chicun-red');
            }
            //            if($('.spec_'+s_id).hasClass('pc-chicun-red')){
            //                $('.spec_'+s_id).removeClass('pc-chicun-red');
            //            }else{
            //                $('.PC-chicun').removeClass('pc-chicun-red');
            //                $('.spec_'+s_id).addClass('pc-chicun-red');
            //            }
            //
            //            $('.m_change_spec_'+id).removeClass('pc-kouwei-red');
            //            $(obj).addClass('pc-kouwei-red');
            var spec_num = "{$spec_count}"; //商品属性数量
            var goods_id = $('input[name=p_goods_id]').val(); //商品id
            //商品属性组合
            var spec_combin = '';
            var len = $('.pc-kouwei-red').length;
            if (len == spec_num) {
                $('.pc-kouwei-red').each(function () {
                    spec_combin += $(this).attr('data-spec-id') + ',';
                })
            } else {
                return false;
            }
            $.post("{:url('GoodsList/pre_calculate_price')}", {
                    goods_id: goods_id,
                    specs: spec_combin
                },
                function (data) {
                    if (data.code == 1) {
                        $('input[name="p_id[]"]').val(data.data.id);
                        $('.p_price').text(data.data.price);
                        $('.kucun').text(data.data.stock);
                    } else {
                        //                        $('input:radio[name^="spec_"]').removeAttr('checked');
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                            $(obj).removeClass('pc-kouwei-red');
                            $('.spec_' + s_id).removeClass('pc-chicun-red');
                        });
                        return false;
                    }
                }
            );
        }
        /**
         * pc端检查订单
         */
        function p_check_form() {
            var uid = "{$Think.session._user_uid_.uid}";
            if (uid == '') {
                layer.msg('您还没有登录，请先去登录', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                    window.location.href = "{:url('Login/loginin')}";
                });
                return false;
            }
            var goods_id = $('input[name=p_goods_id]').val(); //商品id
            var spec_num = "{$spec_count}"; //商品属性数量
            var spec_combin = '';
            var spec_combin = '';
            var len = $('.pc-kouwei-red').length; //已选择的属性长度
            if (len == spec_num) {
                $('.pc-kouwei-red').each(function () {
                    spec_combin += $(this).attr('data-spec-id') + ',';
                })
            } else {
                layer.msg('请选择商品属性', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            $('input[name=p_spec_id]').val(spec_combin);
            $('#p_form').submit();
            return true;
        }
    </script>
    <script>
        /* PC端轮播图*/
        var mySwiper = new Swiper('.swiper-container', {
            pagination: '.pagination',
            paginationClickable: true,
            loop: true,
            autoplay: 3000,
            speed: 1000,
        });
    </script>
    <script>
        /* M端轮播图*/
        var mySwiper = new Swiper('.swiper-container1', {
            pagination: '.pagination1',
            paginationClickable: true,
            loop: true,
            autoplay: 3000,
            speed: 1000,
        });
    </script>
    <script>
        /**
         * PC搜索艺术美食
         */
        function search() {
            var key = $('input[name=p_key]').val();
            window.location.href = "{:url('Index/search')}?key=" + key;
        }
        /**
         * 移动端搜索
         */
        function m_search() {
            var m_key = $('input[name=m_key]').val();
            window.location.href = "{:url('Index/search')}?key=" + m_key;
        }
        /**
         * 返回上一页
         */
        function go_back() {
            window.history.go(-1); //返回上一页
        }
        /**
         * 收藏商品
         * @param goods_id
         */
        function collect_goods(goods_id) {
            $.post("{:url('GoodsList/collect_goods')}", {
                    goods_id: goods_id
                },
                function (data) {
                    if (data.code == 1) {
                        if (data.data == 1) { //收藏
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 1500,
                                shade: 0.1
                            }, function (index) {
                                layer.close(index);
                                $('.collect_pc').text('已收藏');
                            });
                            return false;
                        } else { //取消收藏
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 1500,
                                shade: 0.1
                            }, function (index) {
                                layer.close(index);
                                $('.collect_pc').text('收藏');
                            });
                            return false;
                        }
                    } else {
                        layer.msg(data.msg, {
                            icon: 1,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                        });
                        return false;
                    }
                }
            );
        }
        /**
         * 加入购物车
         * @param sign
         * @returns {boolean}
         */
        function addto_cart(sign) {
            //商品属性数量
            var id = $('input[name="p_id[]"]').val();
            var spec_num = "{$spec_count}";
            var spec_combin = '';
            var num = $('input[name=num]').val();
            //商品id
            var goods_id = $('input[name=p_goods_id]').val();
            var len = $('.pc-kouwei-red').length;
            if (len == spec_num) {
                $('.pc-kouwei-red').each(function () {
                    spec_combin += $(this).attr('data-spec-id') + ',';
                })
            } else {
                layer.msg('请选择商品属性', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            //            for(var i=1;i<=spec_num;i++){
            //                if($('input[name=spec_'+i+']:checked').val() == null){
            //                    var spec_name = $('#spec_'+i).text();
            //                    alert('请选择'+spec_name);
            //                    return false;
            //                }
            //                if($('input[name=spec_'+i+']:checked').val() != null){
            //                    spec_combin += $('input[name=spec_'+i+']:checked').val()+',';
            //                }
            //            }
            $.post("{:url('GoodsList/addto_cart')}", {
                    id: id,
                    goods_id: goods_id,
                    specs: spec_combin,
                    num: num,
                    sign: sign
                },
                function (data) {
                    if (data.code == 1) {
                        layer.msg('加入购物车成功', {
                            icon: 1,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                            location.reload();
                        });
                        return false;
                    } else {
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                        });
                        return false;
                    }
                }
            );
        }
        $(function () {
            if (window.location.search === '') {
                return
            } else {
                var dir = window.location.search;
                if (dir.indexOf("page") > 0) {
                    $('.pingLun').addClass('qiehuan');
                    $('.details').css('display', 'none');
                    $('.comment').css('display', 'block');
                    $('.xiangqing').removeClass('qiehuan');
                }
                //                console.log(window.location.search);
                //                $('.san').parent().children().removeClass("xiangqing-xuan");
                //                $('#review').addClass("xiangqing-xuan");
                //                $('.comment').show();
                //                $('.baobei').hide();
                //                $('.question').hide();
            }
        })
    </script>
</body>

</html>